# Maintainer: George Rawlinson <grawlinson@archlinux.org>

pkgname=cl-trivial-garbage
_pkgname="${pkgname#cl-}"
pkgver=0.21.r8.gb3af9c0
pkgrel=2
pkgdesc='Portable Garbage Collection related APIs for Common Lisp'
arch=('any')
url='https://trivial-garbage.common-lisp.dev/'
license=('custom:Public')
depends=('common-lisp' 'cl-asdf')
makedepends=('git')
checkdepends=('sbcl' 'cl-rt')
_commit='b3af9c0c25d4d4c271545f1420e5ea5d1c892427'
source=(
  "$pkgname::git+https://github.com/trivial-garbage/trivial-garbage#commit=$_commit"
  'run-tests.lisp'
)
b2sums=('SKIP'
        '2b7c57c7c110effa0356d694a99942e4a27ffa38afa1be9c95a7f98e67a9fabb1696f10c174be9c57a90779111bc2b115510ee19edc594f6cd9ea4019e6e7d12')

pkgver() {
  cd "$pkgname"

  git describe --tags | sed -e 's/^v//' -e 's/-/.r/' -e 's/-/./g'
}

prepare() {
  cd "$pkgname"

  # extract license
  sed -n '/^It/p' README.md > LICENSE
}

check() {
  cd "$pkgname"

  sbcl --script ../run-tests.lisp
}

package() {
  cd "$pkgname"

  # library
  install -vDm644 -t "$pkgdir/usr/share/common-lisp/source/$_pkgname" ./*.{lisp,asd} build.xcvb

  # documentation
  install -vDm644 -t "$pkgdir/usr/share/doc/$pkgname" README.md

  # license
  install -vDm644 -t "$pkgdir/usr/share/licenses/$pkgname" LICENSE
}
